//
//  FGUserDefaultUtil.m
//  Mi6App
//
//  Created by Mr.Lemon on 7/26/13.
//  Copyright (c) 2013 4G Secure. All rights reserved.
//

#import "FGUserDefaultUtil.h"

@implementation FGUserDefaultUtil

//Store data
+(void)storeStringWithKey:(NSString*)key andValue:(NSString*)value{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:value forKey:key];
    [defaults synchronize];
    
}
+(void)storeIntWithKey:(NSString*)key andValue:(NSInteger)value{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setInteger:value forKey:key];
    [defaults synchronize];
}
+(void)storeDataWithKey:(NSString*)key andValue:(NSData*)value{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:value forKey:key];
    [defaults synchronize];
}
+(void)storeBooleanWithKey:(NSString*)key andValue:(BOOL)value{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setBool:value forKey:key];
    [defaults synchronize];
}

//Get data
+(NSString*)getStringWithKey:(NSString*)key
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *result = [defaults objectForKey:key];
    return !result?result:@"";
}
+(NSInteger)getIntWithKey:(NSString*)key{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSInteger result= [defaults integerForKey:key];
    return !result?result:0;
}

+(NSData*)getDataWithKey:(NSString*)key{
    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSData *result= [defaults dataForKey:key];
    return result;
    
}
+(bool)getBooleanWithKey:(NSString*)key{
    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    BOOL result= [defaults boolForKey:key];
    return !result?result:FALSE;
}




@end
